/* $Id: ACMComparator.java 67 2010-10-11 10:26:34Z altdotua@gmail.com $ */

package alt.djudge.frontend.server.utils;

import java.util.Comparator;
import alt.djudge.frontend.server.datatypes.scores.ContestUserScoreEntry;

public class ACMComparator implements Comparator<ContestUserScoreEntry>
{

	@Override
	public int compare(ContestUserScoreEntry o1, ContestUserScoreEntry o2)
	{
		int k = o2.getUniqueAcceptedCount() - o1.getUniqueAcceptedCount();
		if (k != 0)
			return k < 0 ? -1 : 1;
		Long t1 = o1.getTotalTime() + o1.getRejectedBeforeAcceptedCount() * 20L;
		Long t2 = o2.getTotalTime() + o2.getRejectedBeforeAcceptedCount() * 20L;
		return t1.compareTo(t2);
	}

}
